/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A 
 * copy of the license can be found in the License.html file at the root of this distribution. If 
 * you cannot locate the  Microsoft Public License, please send an email to 
 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
 * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
 * PARTICULAR PURPOSE.
 * ***************************************************************************/




#if !defined(AFX_PGLVIEW2D_H__338966CB_1C93_11D4_8D89_00409503B978__INCLUDED_)
#define AFX_PGLVIEW2D_H__338966CB_1C93_11D4_8D89_00409503B978__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <pgl/core/PGLObjectRegistry.h>
#include <pgl/core/PGLViewScreen.h>

/*! \brief A 2D view.

\ingroup PGLViewGroup
  This type of view is used for 2D graphs or drawings. 
It can handle basic mouse
events, such as zooming and panning
*/
class PGLCORE_EXT_CLASS CPGLView2D : public CPGLViewScreen
{
PGL_DECLARE_DYNCREATE(CPGLView2D);

public:
    //! \name Constructors
    //@{
    /// default constructor
    CPGLView2D(double _m_dLeft=0,double _right=1,double _top=1,double _bottom=0);
    /// copy constructor
    CPGLView2D(const CPGLView2D& v2D){*this = v2D;};
    /// assignement constructor
    CPGLView2D& operator = (const CPGLView2D& v2D);
    /// destructor
    virtual ~CPGLView2D(){};
	//@}

	//! \name View modification
	//@{
    //!  reconstruct the projection matrice and model matrice
    void Reshape();
    /// pans the view of x (resp. y) pixels horizontaly (resp. verticaly)
    void Pan(int x,int y);
    /// zooms in of 25\%
    void ZoomIn();
    /// zooms out of 25\%
    void ZoomOut();
    /// zooms the box defined by the 2 points (xStart, yStart, xEnd, yEnd)
    void ZoomBox(int xStart,int yStart,int xEnd,int yEnd);
	//! scales the view by x,y
	void ZoomScale(double x, double y);
    /// change the view
	void ZoomAll(double _dLeft,double _dRight, double _dBottom, double _dTop);
	/// Plot to Encapsulated postscript
    void PlotGfx(gfxinterface::CGfxInterface& gfx);
	//@}


	//! \name coordinate transformation
	//@{
    double PixelToWorld(int iaxe, int pix);
    double PixelToWorldCoord(int iaxe, int pix);
    double PixelToWorld(int iaxe, double pix);
    double PixelToWorldCoord(int iaxe, double pix);

	double GetLeft() const	{	return m_dLeft;}
	double GetRight() const	{	return m_dRight;}
	double GetBottom() const	{	return m_dBottom;}
	double GetTop() const	{	return m_dTop;}
	//@}

	//! \name Serialization
	//@{
    /// Serialization
	void SerializeXML(CPGLArchive& ar);
    /// Debuggin functions
#ifdef _DEBUG
    virtual void Dump( CDumpContext& dc ) const;
    virtual void AssertValid() const;    // Override
#endif
    //@}
protected:
    //! \name Class Parameter
    //@{
    /// left limit of the viewport
    double m_dLeft;
    /// right limit of the viewport
    double m_dRight;
    /// top limit of the viewport
    double m_dTop;
    /// bottom limit of the viewport
    double m_dBottom;
    //@}
};

#endif // !defined(AFX_VIEW2DCLASS1_H__338966CB_1C93_11D4_8D89_00409503B978__INCLUDED_)
